var commonParams = {
    domain_path: window.location.protocol + "//" + window.location.host,
    static_path: window.location.protocol + "//static.dodoedu.com",
    files_path: window.location.protocol + "//files.dodoedu.com/photo/"
};
var $ = jQuery = layui.jquery;

//ajax调用公共方法
function AjaxForJson(requestUrl, requestData, SuccessCallback, errorCallback, successPar) {
    jQuery.ajax({
        type: "POST",
        url: requestUrl,
        data: requestData,
        //contentType: "application/json;charset=utf-8",
        //dataType: "json",
        contentType: "application/x-www-form-urlencoded",
        dataType: "text",
        success: function(data) {
            var obj = null;
            try {
                obj = eval('(' + data + ')');
            } catch (ex) {
                obj = data;
            }
            if (obj == null) {
                return;
            }
            if (obj.status == 0) {
                window.location.href = commonParams.dodoDevAccountPath + "/login/login";
            } else if (obj.type == "login") {
                //loginDialog();
                $.cachedScript(commonParams.dodoStaticPathVersion + '/base/login/js/loginQuick.js').done(function() {
                    loginQuickDialog();
                    return false;
                });

            } else {
                if (obj.score) {
                    scoreDialog({
                        scoreNum: obj.score,
                        scoreDescribe: obj.honor_title
                    });
                }
                SuccessCallback(obj, successPar);
            }
            //如果请求不到图片，则显示默认图片
            $('img').error(function() {
                $(this).attr('src', commonParams.dodoStaticPath + '/shequPage/common/image/noFindPic.gif');
                if ($(this).width() > 160) {
                    $(this).css('width', '160px');
                }
            });
        },
        error: function(err) {
            err;
        },
        complete: function(XHR, TS) {
            XHR = null;
        }
    });
}